import { defineStore } from "pinia";

// 登录凭证状态管理
export const useTokenStore = defineStore('token', {
    // 定义数据源
    state: () => {
        return {
            token: ''
        }
    },
    // 数据操作
    actions: {
        setToken(t:string) {
            this.token = t as unknown as string;
        }
    },
    // 持久化
    persist:{
        enabled:true,
        strategies:[
            {
                key:'token',
                storage:localStorage
            }
        ]
    }
})
